package org.finalministry.rest;

import java.sql.SQLException;

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;

import org.finalministry.database.dao.DaoFactory;
import org.finalministry.objects.Territory;

@Path("/territory")
public class ServiceTerritory {

	@GET
	@Path("/{name}")
	@Produces(MediaType.APPLICATION_XML)
	public Territory getCongregation(@PathParam("number") String number) throws ClassNotFoundException, SQLException, Exception {

		if (number == null)
			number = "1";

		Long id = Long.parseLong(number);
		Territory terr = DaoFactory.getInstance().getTerritoryDAO().getById(id);

		return terr;
	}
}
